from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QTextEdit, QProgressBar, QFileDialog
from PySide6.QtGui import QFont
from PySide6.QtCore import Qt
import sys

class MainWindow(QWidget):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("图片处理工具")
        self.setFixedSize(600, 400)

        layout = QVBoxLayout()

        # 设置字体
        font = QFont()
        font.setPointSize(12)  # 增大字体大小

        # 选择图片文件夹部分
        folder_layout = QHBoxLayout()
        folder_label = QLabel("图片文件夹:")
        folder_label.setFont(font)
        self.folder_entry = QLineEdit()
        self.folder_entry.setFont(font)
        folder_btn = QPushButton("选择")
        folder_btn.setFont(font)
        folder_btn.clicked.connect(self.select_image_folder)
        folder_layout.addWidget(folder_label)
        folder_layout.addWidget(self.folder_entry)
        folder_layout.addWidget(folder_btn)

        # 选择贴图文件部分
        sticker_layout = QHBoxLayout()
        sticker_label = QLabel("贴图文件:")
        sticker_label.setFont(font)
        self.sticker_entry = QLineEdit()
        self.sticker_entry.setFont(font)
        sticker_btn = QPushButton("选择")
        sticker_btn.setFont(font)
        sticker_btn.clicked.connect(self.select_sticker_path)
        sticker_layout.addWidget(sticker_label)
        sticker_layout.addWidget(self.sticker_entry)
        sticker_layout.addWidget(sticker_btn)

        # 开始处理按钮
        start_btn = QPushButton("开始处理")
        start_btn.setFont(font)
        start_btn.clicked.connect(self.start_processing)

        # 信息框
        self.info_text = QTextEdit()
        self.info_text.setReadOnly(True)
        self.info_text.setFont(font)

        # 进度条
        self.progress_bar = QProgressBar()
        self.progress_bar.setRange(0, 100)
        self.progress_bar.setAlignment(Qt.AlignmentFlag.AlignCenter)

        layout.addLayout(folder_layout)
        layout.addLayout(sticker_layout)
        layout.addWidget(start_btn)
        layout.addWidget(self.info_text)
        layout.addWidget(self.progress_bar)

        self.setLayout(layout)

    def select_image_folder(self):
        folder_path = QFileDialog.getExistingDirectory(self, "选择图片文件夹")
        self.folder_entry.setText(folder_path)

    def select_sticker_path(self):
        file_path, _ = QFileDialog.getOpenFileName(self, "选择贴图文件", "", "Image files (*.jpg *.png *.jpeg *.webp)")
        self.sticker_entry.setText(file_path)

    def start_processing(self):
        # 这里添加实际的处理逻辑
        self.info_text.append("开始处理图片...")
        # 假设处理过程分10步
        for i in range(10):
            # 模拟处理进度
            self.progress_bar.setValue(i * 10)
            QApplication.processEvents()
            # 这里可以添加实际处理代码

        self.info_text.append("处理完成！")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec())